package com.hs.srm.admin.modules.sequence.entity;

import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import com.hs.srm.base.common.base.CloneableEntity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * 序列实体类，用于实现某些自增需求
 *
 * @author ych
 * @since 2020-05-08 14:15:14
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName("sequence")
public class SequenceEntity implements Serializable, CloneableEntity<SequenceEntity> {

    private static final long serialVersionUID = -87693987746048155L;

    @TableId(value = "pk_id")
    @TableField("pk_id")
    private Integer pkId;

    /**
     * 序列名称
     */
    @TableField("seq_name")
    private String seqName;

    /**
     * 当前值
     */
    @TableField("current_val")
    private Integer currentVal;

    /**
     * 每次增长值
     */
    @TableField("increment_val")
    private Integer incrementVal;

    @Override
    public SequenceEntity clone() {
        try {
            return (SequenceEntity) super.clone();
        } catch (CloneNotSupportedException ex) {
            ex.printStackTrace();
        }
        return null;
    }
}